package com.king.security.ctrl;

import com.king.security.config.TestProperties;
import com.king.security.entity.MyUser;
import com.king.security.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author KING
 * @date 2018/8/30 17:52
 */
@Controller
@RequestMapping("login")
public class LoginControl {

    @Autowired
    public TestProperties testProperties;

    @Autowired
    public UserService userService;

    @GetMapping
    public String login() {
        System.out.println("login---");
        return "login/login";
    }

    @GetMapping(value = "index")
    public String index() {
        System.out.println("index---");
        return "login/index";
    }

    @GetMapping(value = "getUsers")
    @ResponseBody
    public List<MyUser> getUsers() {
        List<MyUser> users = userService.findAll();
        System.out.println("getUsers---" + users.toString());
        return users;
    }
}